\documentclass[11pt,letterpaper,oneside]{book}

% 中文支持与排版
\usepackage[UTF8]{ctex}

% 页面布局
\usepackage[margin=1in]{geometry}
\usepackage{setspace}
\usepackage{fancyhdr}
\usepackage{titlesec}

% 字体与排印
\usepackage[T1]{fontenc}
\usepackage{lmodern}
\usepackage{microtype}

% 颜色与图形
\usepackage{xcolor}
\usepackage{graphicx}
\usepackage{tikz}

% 代码高亮
\usepackage{listings}

% 表格
\usepackage{booktabs}
\usepackage{tabularx}
\usepackage{longtable}

% 超链接
\usepackage{hyperref}
\usepackage{bookmark}

% 索引与术语表
\usepackage{makeidx}
\usepackage{glossaries}

% 其他辅助
\usepackage{enumitem}
\usepackage{caption}
\usepackage{subcaption}

\definecolor{codeblue}{rgb}{0.13,0.13,0.82}
\definecolor{codegreen}{rgb}{0,0.6,0}
\definecolor{codegray}{rgb}{0.5,0.5,0.5}
\definecolor{codepurple}{rgb}{0.58,0,0.82}
\definecolor{backcolour}{rgb}{0.95,0.95,0.92}
\definecolor{linkcolor}{rgb}{0.0,0.2,0.6}
\definecolor{urlcolor}{rgb}{0.0,0.4,0.8}
\definecolor{citecolor}{rgb}{0.0,0.5,0.3}

\lstset{
    language=C++,
    backgroundcolor=\color{backcolour},
    commentstyle=\color{codegreen},
    keywordstyle=\color{codeblue}\bfseries,
    numberstyle=\tiny\color{codegray},
    stringstyle=\color{codepurple},
    basicstyle=\ttfamily\footnotesize,
    breaklines=true,
    captionpos=b,
    keepspaces=true,
    numbers=left,
    numbersep=5pt,
    showspaces=false,
    showstringspaces=false,
    showtabs=false,
    tabsize=2,
    frame=single,
    frameround=tttt,
    rulecolor=\color{black!30}
}

\lstdefinestyle{cpp}{
    language=C++,
    backgroundcolor=\color{backcolour},
    commentstyle=\color{codegreen},
    keywordstyle=\color{codeblue}\bfseries,
    numberstyle=\tiny\color{codegray},
    stringstyle=\color{codepurple},
    basicstyle=\ttfamily\footnotesize,
    breaklines=true,
    captionpos=b,
    keepspaces=true,
    numbers=left,
    numbersep=5pt,
    showspaces=false,
    showstringspaces=false,
    showtabs=false,
    tabsize=2,
    frame=single,
    frameround=tttt,
    rulecolor=\color{black!30},
    morekeywords={constexpr,nullptr,override,final,noexcept}
}

\lstdefinestyle{csharp}{
    language=[Sharp]C,
    backgroundcolor=\color{backcolour},
    commentstyle=\color{codegreen},
    keywordstyle=\color{codeblue}\bfseries,
    numberstyle=\tiny\color{codegray},
    stringstyle=\color{codepurple},
    basicstyle=\ttfamily\footnotesize,
    breaklines=true,
    captionpos=b,
    keepspaces=true,
    numbers=left,
    numbersep=5pt,
    showspaces=false,
    showstringspaces=false,
    showtabs=false,
    tabsize=2,
    frame=single,
    frameround=tttt,
    rulecolor=\color{black!30}
}

\lstdefinestyle{bash}{
    language=bash,
    backgroundcolor=\color{backcolour},
    commentstyle=\color{codegreen},
    keywordstyle=\color{codeblue}\bfseries,
    numberstyle=\tiny\color{codegray},
    stringstyle=\color{codepurple},
    basicstyle=\ttfamily\footnotesize,
    breaklines=true,
    captionpos=b,
    keepspaces=true,
    showspaces=false,
    showstringspaces=false,
    showtabs=false,
    tabsize=2,
    frame=single,
    frameround=tttt,
    rulecolor=\color{black!30}
}

\lstdefinestyle{json}{
    backgroundcolor=\color{backcolour},
    commentstyle=\color{codegreen},
    keywordstyle=\color{codeblue}\bfseries,
    numberstyle=\tiny\color{codegray},
    stringstyle=\color{codepurple},
    basicstyle=\ttfamily\footnotesize,
    breaklines=true,
    captionpos=b,
    keepspaces=true,
    showspaces=false,
    showstringspaces=false,
    showtabs=false,
    tabsize=2,
    frame=single,
    frameround=tttt,
    rulecolor=\color{black!30}
}

\lstdefinelanguage{yaml}{
    keywords={true,false,null,yes,no},
    keywordstyle=\color{codeblue}\bfseries,
    basicstyle=\ttfamily\footnotesize,
    comment=[l]{\#},
    commentstyle=\color{codegreen},
    stringstyle=\color{codepurple},
    morestring=[b]',
    morestring=[b]",
    sensitive=false
}

\lstdefinestyle{yaml}{
    language=yaml,
    backgroundcolor=\color{backcolour},
    keywordstyle=\color{codeblue}\bfseries,
    commentstyle=\color{codegreen},
    stringstyle=\color{codepurple},
    numberstyle=\tiny\color{codegray},
    basicstyle=\ttfamily\footnotesize,
    breaklines=true,
    captionpos=b,
    keepspaces=true,
    showspaces=false,
    showstringspaces=false,
    showtabs=false,
    tabsize=2,
    frame=single,
    frameround=tttt,
    rulecolor=\color{black!30}
}

\hypersetup{
    colorlinks=true,
    linkcolor=linkcolor,
    urlcolor=urlcolor,
    citecolor=citecolor,
    pdftitle={C\# 到 C++ 转换系统中文手册},
    pdfauthor={cpp-orchestrator 团队},
    pdfsubject={用户手册},
    pdfkeywords={CSharp,C++,转换,cpp-orchestrator},
    bookmarksnumbered=true,
    pdfstartview={FitH}
}

\pagestyle{fancy}
\fancyhf{}
\fancyhead[L]{\nouppercase{\leftmark}}
\fancyhead[R]{\thepage}
\fancyfoot[C]{cpp-orchestrator 中文用户手册}
\setlength{\headheight}{14pt}
\addtolength{\topmargin}{-2pt}
\renewcommand{\headrulewidth}{0.4pt}
\renewcommand{\footrulewidth}{0.4pt}

\fancypagestyle{plain}{
    \fancyhf{}
    \fancyfoot[C]{cpp-orchestrator 中文用户手册}
    \fancyfoot[R]{\thepage}
    \renewcommand{\headrulewidth}{0pt}
    \renewcommand{\footrulewidth}{0.4pt}
}

\title{C\# 到 C++ 转换系统\protect\\中文用户手册}
\author{cpp-orchestrator 团队}
\date{2025 年 10 月}

\makeindex
\makeglossaries

\newcommand{\important}[1]{%
    \begin{center}
    \fcolorbox{red}{yellow!20}{
        \parbox{0.9\textwidth}{\textbf{重要提示：} #1}
    }
    \end{center}}

\newcommand{\tip}[1]{%
    \begin{center}
    \fcolorbox{blue}{blue!10}{
        \parbox{0.9\textwidth}{\textbf{小贴士：} #1}
    }
    \end{center}}

\newcommand{\warning}[1]{%
    \begin{center}
    \fcolorbox{orange}{orange!20}{
        \parbox{0.9\textwidth}{\textbf{警告：} #1}
    }
    \end{center}}

\newcommand{\filepath}[1]{\texttt{#1}}
\newcommand{\cmd}[1]{\texttt{#1}}
\newcommand{\code}[1]{\texttt{#1}}

\begin{document}
\frontmatter
\maketitle
\tableofcontents
\listoffigures
\listoftables

\mainmatter

\include{chapters/01-introduction}
\include{chapters/02-installation-linux}
\include{chapters/03-installation-windows}
\include{chapters/04-getting-started}
\include{chapters/05-usage-guide}
\include{chapters/06-examples}
\include{chapters/07-troubleshooting}
\include{chapters/08-advanced-topics}

\appendix
\include{appendices/a-commandref}
\include{appendices/b-errors}
\include{appendices/c-glossary}

\backmatter
\printindex
\printglossary

\end{document}
